#include "stdafx.h"

#ifndef DLL_SSE_CPP
#define DLL_SSE_CPP

#include "SSE.h"


struct Float4{
	__m128 sse;
};

BBAEXPint Float4Create()
{
	return rcast_i( _aligned_malloc(sizeof(Float4), 16) );
}

BBAEXPvoid Float4Free( const int float4_ptr )
{
	_aligned_free( rcast_v(float4_ptr) );
}

BBAEXPvoid Float4Set( const int float4_ptr, const float a, const float b, const float c, const float d )
{
	rcast_f4(float4_ptr)->sse = _mm_set_ps( d, c, b, a );
}

BBAEXPfloat Float4Get( const int float4_ptr, const int index )
{
	return rcast_f4(float4_ptr)->sse.m128_f32[index];
}

BBAEXPvoid Float4Add( const int float4_ptr0, const int float4_ptr1 )
{
	rcast_f4(float4_ptr0)->sse = _mm_add_ps( rcast_f4(float4_ptr0)->sse, rcast_f4(float4_ptr1)->sse );
}

BBAEXPvoid Float4Sub( const int float4_ptr0, const int float4_ptr1 )
{
	rcast_f4(float4_ptr0)->sse = _mm_sub_ps( rcast_f4(float4_ptr0)->sse, rcast_f4(float4_ptr1)->sse );
}

BBAEXPvoid Float4Mul( const int float4_ptr0, const int float4_ptr1 )
{
	rcast_f4(float4_ptr0)->sse = _mm_mul_ps( rcast_f4(float4_ptr0)->sse, rcast_f4(float4_ptr1)->sse );
}

BBAEXPvoid Float4Div( const int float4_ptr0, const int float4_ptr1 )
{
	rcast_f4(float4_ptr0)->sse = _mm_div_ps( rcast_f4(float4_ptr0)->sse, rcast_f4(float4_ptr1)->sse );
}

BBAEXPvoid Float4Min( const int float4_ptr0, const int float4_ptr1 )
{
	rcast_f4(float4_ptr0)->sse = _mm_min_ps( rcast_f4(float4_ptr0)->sse, rcast_f4(float4_ptr1)->sse );
}

BBAEXPvoid Float4Max( const int float4_ptr0, const int float4_ptr1 )
{
	rcast_f4(float4_ptr0)->sse = _mm_max_ps( rcast_f4(float4_ptr0)->sse, rcast_f4(float4_ptr1)->sse );
}

BBAEXPvoid Float4Sqrt( const int float4_ptr )
{
	rcast_f4(float4_ptr)->sse = _mm_sqrt_ps( rcast_f4(float4_ptr)->sse );
}

#endif //DLL_SSE_CPP